<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.10"/>
<title>eeprom.h Source File</title>
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="../../vesc.jpg"/></td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.10 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "../../search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="../../index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="../../pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="../../modules.html"><span>Modules</span></a></li>
      <li><a href="../../annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="../../files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="../../search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="../../search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="../../files.html"><span>File&#160;List</span></a></li>
      <li><a href="../../globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">eeprom.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="../../d0/ded/eeprom_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;</div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;<span class="comment">/* Define to prevent recursive inclusion -------------------------------------*/</span></div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;<span class="preprocessor">#ifndef __EEPROM_H</span></div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;<span class="preprocessor">#define __EEPROM_H</span></div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;</div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;<span class="comment">/* Includes ------------------------------------------------------------------*/</span></div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;<span class="preprocessor">#include &quot;stm32f4xx.h&quot;</span></div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;</div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;<span class="comment">/* Exported constants --------------------------------------------------------*/</span></div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;<span class="comment">/* Define the size of the sectors to be used */</span></div>
<div class="line"><a name="l00032"></a><span class="lineno"><a class="line" href="../../d0/ded/eeprom_8h.html#a7d467c1d283fdfa1f2081ba1e0d01b6e">   32</a></span>&#160;<span class="preprocessor">#define PAGE_SIZE               (uint32_t)0x4000  </span><span class="comment">/* Page size = 16KByte */</span><span class="preprocessor"></span></div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;</div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;<span class="comment">/* Device voltage range supposed to be [2.7V to 3.6V], the operation will</span></div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;<span class="comment">   be done by word  */</span></div>
<div class="line"><a name="l00036"></a><span class="lineno"><a class="line" href="../../d0/ded/eeprom_8h.html#ae724813bd5ec56ea9778340c3271c256">   36</a></span>&#160;<span class="preprocessor">#define VOLTAGE_RANGE           (uint8_t)VoltageRange_3</span></div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;</div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;<span class="comment">/* EEPROM start address in Flash */</span></div>
<div class="line"><a name="l00039"></a><span class="lineno"><a class="line" href="../../d0/ded/eeprom_8h.html#a96932befbe81496318633eab6e623adb">   39</a></span>&#160;<span class="preprocessor">#define EEPROM_START_ADDRESS  ((uint32_t)0x08004000) </span><span class="comment">/* EEPROM emulation start address:</span></div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;<span class="comment">                                                  from sector1 : after 16KByte of used</span></div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;<span class="comment">                                                  Flash memory */</span><span class="preprocessor"></span></div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;<span class="comment">/* Pages 0 and 1 base and end addresses */</span></div>
<div class="line"><a name="l00044"></a><span class="lineno"><a class="line" href="../../d0/ded/eeprom_8h.html#a062c18f12dc7f6d4b74597059a87aa36">   44</a></span>&#160;<span class="preprocessor">#define PAGE0_BASE_ADDRESS    ((uint32_t)(EEPROM_START_ADDRESS + 0x0000))</span></div>
<div class="line"><a name="l00045"></a><span class="lineno"><a class="line" href="../../d0/ded/eeprom_8h.html#a033d1b9c3ce59690ffcdef7c500857d8">   45</a></span>&#160;<span class="preprocessor">#define PAGE0_END_ADDRESS     ((uint32_t)(EEPROM_START_ADDRESS + (PAGE_SIZE - 1)))</span></div>
<div class="line"><a name="l00046"></a><span class="lineno"><a class="line" href="../../d0/ded/eeprom_8h.html#add3aaa7d2d73e26b4345e9bdc188adf7">   46</a></span>&#160;<span class="preprocessor">#define PAGE0_ID              FLASH_Sector_1</span></div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;</div>
<div class="line"><a name="l00048"></a><span class="lineno"><a class="line" href="../../d0/ded/eeprom_8h.html#a199f308fcbd4d6ec1adc01a23a1ab10e">   48</a></span>&#160;<span class="preprocessor">#define PAGE1_BASE_ADDRESS    ((uint32_t)(EEPROM_START_ADDRESS + 0x4000))</span></div>
<div class="line"><a name="l00049"></a><span class="lineno"><a class="line" href="../../d0/ded/eeprom_8h.html#a687a6117fcecbc1763f3ebcd903dd22e">   49</a></span>&#160;<span class="preprocessor">#define PAGE1_END_ADDRESS     ((uint32_t)(EEPROM_START_ADDRESS + (2 * PAGE_SIZE - 1)))</span></div>
<div class="line"><a name="l00050"></a><span class="lineno"><a class="line" href="../../d0/ded/eeprom_8h.html#a52419d2550c760ae3b4d3b39630ad9b2">   50</a></span>&#160;<span class="preprocessor">#define PAGE1_ID              FLASH_Sector_2</span></div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;<span class="comment">/* Used Flash pages for EEPROM emulation */</span></div>
<div class="line"><a name="l00053"></a><span class="lineno"><a class="line" href="../../d0/ded/eeprom_8h.html#a2a04f7bf0fe13871f7d1c220e4b78acf">   53</a></span>&#160;<span class="preprocessor">#define PAGE0                 ((uint16_t)0x0000)</span></div>
<div class="line"><a name="l00054"></a><span class="lineno"><a class="line" href="../../d0/ded/eeprom_8h.html#a76461f9c28fe509ce976b40a489a57e4">   54</a></span>&#160;<span class="preprocessor">#define PAGE1                 ((uint16_t)0x0001)</span></div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;<span class="comment">/* No valid page define */</span></div>
<div class="line"><a name="l00057"></a><span class="lineno"><a class="line" href="../../d0/ded/eeprom_8h.html#a4df3477464bc078623a7f55e7bcd9be0">   57</a></span>&#160;<span class="preprocessor">#define NO_VALID_PAGE         ((uint16_t)0x00AB)</span></div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;<span class="comment">/* Page status definitions */</span></div>
<div class="line"><a name="l00060"></a><span class="lineno"><a class="line" href="../../d0/ded/eeprom_8h.html#ab34c8a09ba45ac4f5eca4545edb690d2">   60</a></span>&#160;<span class="preprocessor">#define ERASED                ((uint16_t)0xFFFF)     </span><span class="comment">/* Page is empty */</span><span class="preprocessor"></span></div>
<div class="line"><a name="l00061"></a><span class="lineno"><a class="line" href="../../d0/ded/eeprom_8h.html#ab19a68e9d28176fa03de1520a2f412a1">   61</a></span>&#160;<span class="preprocessor">#define RECEIVE_DATA          ((uint16_t)0xEEEE)     </span><span class="comment">/* Page is marked to receive data */</span><span class="preprocessor"></span></div>
<div class="line"><a name="l00062"></a><span class="lineno"><a class="line" href="../../d0/ded/eeprom_8h.html#a7212a28cabb1d59cdad2ce997350911c">   62</a></span>&#160;<span class="preprocessor">#define VALID_PAGE            ((uint16_t)0x0000)     </span><span class="comment">/* Page containing valid data */</span><span class="preprocessor"></span></div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;<span class="comment">/* Valid pages in read and write defines */</span></div>
<div class="line"><a name="l00065"></a><span class="lineno"><a class="line" href="../../d0/ded/eeprom_8h.html#a05987e5911ecd1a80bfbff03622d5bbc">   65</a></span>&#160;<span class="preprocessor">#define READ_FROM_VALID_PAGE  ((uint8_t)0x00)</span></div>
<div class="line"><a name="l00066"></a><span class="lineno"><a class="line" href="../../d0/ded/eeprom_8h.html#abd6dfb57e2c1eb0d9091b46d1a33dd49">   66</a></span>&#160;<span class="preprocessor">#define WRITE_IN_VALID_PAGE   ((uint8_t)0x01)</span></div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;<span class="comment">/* Page full define */</span></div>
<div class="line"><a name="l00069"></a><span class="lineno"><a class="line" href="../../d0/ded/eeprom_8h.html#ac62392d0ebdd165defbbc36f7262a385">   69</a></span>&#160;<span class="preprocessor">#define PAGE_FULL             ((uint8_t)0x80)</span></div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;<span class="comment">/* Variables&#39; number */</span></div>
<div class="line"><a name="l00072"></a><span class="lineno"><a class="line" href="../../d0/ded/eeprom_8h.html#a8bae73a7ce70b5cae64c6e0d485daa2f">   72</a></span>&#160;<span class="preprocessor">#define NB_OF_VAR             ((uint8_t)160)</span></div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;</div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;<span class="comment">/* Exported types ------------------------------------------------------------*/</span></div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;<span class="comment">/* Exported macro ------------------------------------------------------------*/</span></div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;<span class="comment">/* Exported functions ------------------------------------------------------- */</span></div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;uint16_t <a class="code" href="../../de/d29/group___e_e_p_r_o_m___emulation.html#ga83834957567411c76bb7f659cf8a1a38">EE_Init</a>(<span class="keywordtype">void</span>);</div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;uint16_t <a class="code" href="../../de/d29/group___e_e_p_r_o_m___emulation.html#ga0776e2e16f54d3a675e4f2f401703a85">EE_ReadVariable</a>(uint16_t VirtAddress, uint16_t* Data);</div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;uint16_t <a class="code" href="../../de/d29/group___e_e_p_r_o_m___emulation.html#ga516e9ced7438b9452c72884aa1df5915">EE_WriteVariable</a>(uint16_t VirtAddress, uint16_t Data);</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;<span class="preprocessor">#endif </span><span class="comment">/* __EEPROM_H */</span><span class="preprocessor"></span></div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;</div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;<span class="comment">/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/</span></div>
<div class="ttc" id="group___e_e_p_r_o_m___emulation_html_ga516e9ced7438b9452c72884aa1df5915"><div class="ttname"><a href="../../de/d29/group___e_e_p_r_o_m___emulation.html#ga516e9ced7438b9452c72884aa1df5915">EE_WriteVariable</a></div><div class="ttdeci">uint16_t EE_WriteVariable(uint16_t VirtAddress, uint16_t Data)</div><div class="ttdoc">Writes/upadtes variable data in EEPROM. </div><div class="ttdef"><b>Definition:</b> eeprom.c:328</div></div>
<div class="ttc" id="group___e_e_p_r_o_m___emulation_html_ga83834957567411c76bb7f659cf8a1a38"><div class="ttname"><a href="../../de/d29/group___e_e_p_r_o_m___emulation.html#ga83834957567411c76bb7f659cf8a1a38">EE_Init</a></div><div class="ttdeci">uint16_t EE_Init(void)</div><div class="ttdoc">Restore the pages to a known good state in case of page&#39;s status corruption after a power loss...</div><div class="ttdef"><b>Definition:</b> eeprom.c:54</div></div>
<div class="ttc" id="group___e_e_p_r_o_m___emulation_html_ga0776e2e16f54d3a675e4f2f401703a85"><div class="ttname"><a href="../../de/d29/group___e_e_p_r_o_m___emulation.html#ga0776e2e16f54d3a675e4f2f401703a85">EE_ReadVariable</a></div><div class="ttdeci">uint16_t EE_ReadVariable(uint16_t VirtAddress, uint16_t *Data)</div><div class="ttdoc">Returns the last stored variable data, if found, which correspond to the passed virtual address...</div><div class="ttdef"><b>Definition:</b> eeprom.c:269</div></div>
</div><!-- fragment --></div><!-- contents -->
<hr class="footer"/><address class="footer"><small>
Generated by <a href="https://github.com/joshdellay" target="_new">Josh Dellay</a>